package com.zhang.serviceorder.controller;

import com.zhang.internalcommon.dto.OrderInfo;
import com.zhang.serviceorder.mapper.OrderInfoMapper;
import com.zhang.serviceorder.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类功能描述
 *
 * @author Kye
 * @date 2025-04-19
 */
@RestController
public class TestController {

	@GetMapping("/test")
	public String test(){
		return "service-order test";
	}


	@Autowired
	OrderInfoService orderInfoService;

	@Autowired
	OrderInfoMapper orderInfoMapper;

	@Value("${server.port}")
	String port;

	/**
	 * 测试派单逻辑
	 * @param orderId
	 * @return
	 */
	@GetMapping("/test-real-time-order/{orderId}")
	public String dispatchRealTimeOrder(@PathVariable("orderId") long orderId){
		System.out.println("service-order 端口："+ port+" 并发测试：orderId："+orderId);
		OrderInfo orderInfo = orderInfoMapper.selectById(orderId);
		orderInfoService.dispatchRealTimeOrder(orderInfo);
		return "test-real-time-order   success";
	}
}